package oss.aliyun.springai.Controller;

import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import static org.springframework.ai.chat.client.advisor.AbstractChatMemoryAdvisor.CHAT_MEMORY_CONVERSATION_ID_KEY;

/**
 * @Author: 陈杰
 * @Date: 2025/4/16 20:07
 * @Description:
 * @PackageName: oss.aliyun.springai.Controller
 * @Version: 1.0
 * @Since: 1.0
 */
@RequestMapping("/ai")
@RequiredArgsConstructor
@RestController
public class GameChatController {
    private final ChatClient GamechatClient ;
    @RequestMapping(value = "/game",produces="text/html;charset=utf-8")
    public Flux<String> Gamechat(String prompt, String chatId) {
        return GamechatClient.prompt()
                .user(prompt)
                .advisors(a -> a.param(CHAT_MEMORY_CONVERSATION_ID_KEY, chatId))
                .stream()
                .content();
    }
}
